#include <map>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
map<int,map<int,int> > edges;
int N;
int M;
const int maxN = 100000;
bool triangle(int s, int t)
{
    int path[maxN + 1];
    for(int i=0;i<maxN+1;i++) path[i]=0;

    vector<int> newNode;
    newNode.push_back(s);
    path[s]=s;
    while (path[t] == 0 && newNode.size()>0){
       vector<int> nn = newNode;
       newNode.clear();
       for (vector<int>::iterator i = nn.begin();i!=nn.end();i++) {
            map<int,int> dests = edges[*i];
            for (map<int,int>::iterator p= dests.begin();p!=dests.end();p++)
            {
                int j = p->first;
                if (path[j] == 0) {
                    path[j] = *i;
                    newNode.push_back(j);
                }
            }
       }
    }
    vector<int> route;
    int dest = t;
    while (dest != s) {
        int source = path[dest];
        route.push_back(edges[source][dest]);
        dest = source;
    }
    sort(route.begin(),route.end());
    //cout<<"route.size = " << route.size()<<endl;
    for (int i=0; i<(int)route.size()-2;i++) {
        int a = route[i];
        int b = route[i+1];
        int c = route[i+2];
        if (a+b > c) {
            //cout << a<< " " << b<<" "<<c<<endl;
            return true;
        }

    }
    return false;
}
int main()
{
    int T;
    int N,M;
    int a,b,len;
    int src,dest;
    cin>>T;
    for (int t=1;t<=T;t++) {
        cin>>N;
        edges.clear();
        for (int i=0;i<N-1;i++){
            cin>>a>>b>>len;
            edges[a][b]=edges[b][a]=len;
        }
        cin>>M;
        cout<<"Case #"<<t<<":"<<endl;
        for(int m=1;m<=M;m++){
            cin>>src>>dest;
            if(triangle(src,dest))
                cout<<"Yes";
            else
                cout<<"No";
            if(t<T || m <M)
                cout<<endl;
        }
    }
}
